var _n22;
var i;
var cc__extends = __extends;
var cc__decorate = __decorate;
Object.defineProperty(exports, "__esModule", {
  value: true
});
(function (t) {
  t[t.NULL = 0] = "NULL";
  t[t.SLIGHT_WAGGLE = 1] = "SLIGHT_WAGGLE";
  t[t.SCALE = 2] = "SCALE";
})(i || (i = {}));
var cc__decorator = cc._decorator;
var ccp_ccclass = cc__decorator.ccclass;
var ccp_property = cc__decorator.property;
var ccp_menu = cc__decorator.menu;
var def_Ipha_SimpleAni_icon = function (t) {
  function _ctor() {
    // 创建实例并设置默认属性
    const instance = null !== t && t.apply(this, arguments) || this;

    // 设置动画类型和相关属性
    instance.aniType = i.NULL; // 动画类型
    instance.isAutoStart = true; // 是否自动开始
    instance.isLoop = true; // 是否循环
    instance.angleValue = 5; // 角度值
    instance.slightWaggleTime = 0.1; // 轻微摇摆时间
    instance._scaleDelay = 1; // 缩放延迟
    instance._scaleSpeed = 0.3; // 缩放速度
    instance._xScaleMax = 0.1; // X轴最大缩放
    instance._xScaleMin = 0.1; // X轴最小缩放
    instance._yScaleMax = 0.1; // Y轴最大缩放
    instance._yScaleMin = 0.1; // Y轴最小缩放
    instance.repeatCnt = 0; // 重复计数
    instance.tag = 1001; // 标记

    return instance; // 返回实例
  }
  cc__extends(_ctor, t);
  _ctor.prototype.start = function () {
    if (this.isAutoStart) {
      this.playAni();
    }
  };
  _ctor.prototype.playAni = function () {
    if (this.aniType != i.NULL) {
      this.aniList()[this.aniType]();
    }
  };
  _ctor.prototype.aniList = function () {
    return [null, this.slightWaggle.bind(this), this.scale.bind(this)];
  };
  _ctor.prototype.slightWaggle = function () {
    // 创建动画根据是否循环来选择不同的行为
    const tween = cc.tween(this.node).tag(this.tag); // 创建 tween 实例并设置标签

    // 设置轻微摇摆的动画序列
    const waggleSequence = cc.tween()
      .to(this.slightWaggleTime, { angle: this.angleValue })
      .to(this.slightWaggleTime, { angle: -this.angleValue });

    // 检查是否循环
    if (this.isLoop) {
      // 使用 repeatForever 方法进行无限循环
      tween.sequence(waggleSequence, waggleSequence).repeatForever().start();
    } else {
      // 如果不是循环，设置重复次数
      this.repeatCnt = this.repeatCnt || 1; // 如果 repeatCnt 未定义，则默认为 1
      tween.sequence(waggleSequence, waggleSequence).repeat(this.repeatCnt).start();
    }
  };
  _ctor.prototype.scale = function () {
    const initialScaleX = this.node.scaleX; // 获取初始 X 轴缩放
    const initialScaleY = this.node.scaleY; // 获取初始 Y 轴缩放

    // 创建缩放动画的 tween 实例
    const scaleTween = cc.tween(this.node).sequence(
      cc.tween().to(this._scaleSpeed, {
        scaleX: initialScaleX + this._xScaleMax,
        scaleY: initialScaleY + this._yScaleMax
      }),
      cc.tween().to(this._scaleSpeed, {
        scaleX: initialScaleX - this._xScaleMin,
        scaleY: initialScaleY - this._yScaleMin
      })
    );

    // 根据是否循环决定动画的类型
    if (this.isLoop) {
      scaleTween.repeatForever().start(); // 无限循环
    } else {
      this.repeatCnt = this.repeatCnt || 1; // 如果 repeatCnt 未定义，则默认为 1
      scaleTween.repeat(this.repeatCnt).start(); // 指定重复次数
    }
  };
  _ctor.prototype.stopAni = function () {
    this.node.stopActionByTag(this.tag);
  };
  cc__decorate([ccp_property({
    type: cc.Enum(i),
    displayName: "动画类型",
    tooltip: "空\n        轻微左右晃动\n        呼吸缩放"
  })], _ctor.prototype, "aniType", undefined);
  cc__decorate([ccp_property({
    displayName: "自动开始"
  })], _ctor.prototype, "isAutoStart", undefined);
  cc__decorate([ccp_property({
    displayName: "是否循环播放",
    visible() {
      return this.aniType == i.SLIGHT_WAGGLE || this.aniType == i.SCALE;
    }
  })], _ctor.prototype, "isLoop", undefined);
  cc__decorate([ccp_property({
    displayName: "震动幅度",
    visible() {
      return this.aniType == i.SLIGHT_WAGGLE;
    }
  })], _ctor.prototype, "angleValue", undefined);
  cc__decorate([ccp_property({
    displayName: "震动速度",
    visible() {
      return this.aniType == i.SLIGHT_WAGGLE;
    }
  })], _ctor.prototype, "slightWaggleTime", undefined);
  cc__decorate([ccp_property({
    displayName: "呼吸缩放 延迟",
    visible() {
      return this.aniType == i.SCALE;
    }
  })], _ctor.prototype, "_scaleDelay", undefined);
  cc__decorate([ccp_property({
    displayName: "呼吸缩放 速度",
    visible() {
      return this.aniType == i.SCALE;
    }
  })], _ctor.prototype, "_scaleSpeed", undefined);
  cc__decorate([ccp_property({
    displayName: "横轴缩放MAX",
    visible() {
      return this.aniType == i.SCALE;
    }
  })], _ctor.prototype, "_xScaleMax", undefined);
  cc__decorate([ccp_property({
    displayName: "横轴缩放MIN",
    visible() {
      return this.aniType == i.SCALE;
    }
  })], _ctor.prototype, "_xScaleMin", undefined);
  cc__decorate([ccp_property({
    displayName: "竖轴缩放MAX",
    visible() {
      return this.aniType == i.SCALE;
    }
  })], _ctor.prototype, "_yScaleMax", undefined);
  cc__decorate([ccp_property({
    displayName: "竖轴缩放MIN",
    visible() {
      return this.aniType == i.SCALE;
    }
  })], _ctor.prototype, "_yScaleMin", undefined);
  cc__decorate([ccp_property({
    displayName: "循环次数",
    visible() {
      return !this.isLoop;
    }
  })], _ctor.prototype, "repeatCnt", undefined);
  return cc__decorate([ccp_ccclass, ccp_menu("ipha组件/简单icon动画01")], _ctor);
}(cc.Component);
exports.default = def_Ipha_SimpleAni_icon;